<template>
  <div class="home_container">
    <el-container class="containers">
      <el-header>
        <div class="header">
          <img src="../assets/logo.png" alt="" />
          <h2>后台管理系统</h2>
        </div>
        <el-button type="info" @click="goBack">退出</el-button></el-header
      >
      <!-- 左右侧边栏 -->
      <el-container>
        <!-- 左侧 -->
        <el-aside width="200px">
          <el-menu default-active="2"  background-color="#333744" text-color="#fff" >
            <el-submenu index="itme.id" v-for="item in menulist" :key='item.id'>
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{item.authName}}</span>
              </template>

              <el-menu-item index="1" ></el-menu-item>
              <el-menu-item index="1-2"></el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <!-- 右侧 -->
        <el-main>Main</el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data () {
    return {
      menulist: []
    }
  },
  created () {
    this.getmenulist()
  },
  methods: {
    goBack () {
      window.sessionStorage.removeItem('token')
      this.$router.push('/login')
    },
    async getmenulist () {
      const { data: res } = await this.$http.get('/menus')
      this.menulist = res.data
      console.log(res)
    }
  }
}
</script>
<style lang="less" scoped>
.home_container {
  height: 100%;
  .containers {
    height: 100%;
    .el-header {
      background-color: #373d41;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 23px;
        color: #fff;
        img {
          width: 50px;
          height: 50px;
          margin-right: 20px;
        }
      }
    }
    .el-aside {
      background-color: #333744;
    }
    .el-main {
      background-color: #eaedfa;
    }
  }
}
</style>
